import { User, UserProfile } from '@/types/data'
import { ProfileAction } from '@/types/store'

type ProfileState = {
  user: User,
  userProfile: UserProfile
}

const initValue = {
  user: {},
  userProfile: {}
} as ProfileState


export default function profile(state = initValue, action: ProfileAction) {
  if (action.type === 'profile/getUser') {
    return {
      ...state,
      user: action.payload
    }
  }
  if (action.type === 'profile/getUserProfile') {
    return {
      ...state,
      userProfile: action.payload
    }
  }
  return state
}